import fetch from '../fetch';

export async function getPublishedArticlesByType(params) {
  const opt = {
    url: '/getPublishedArticlesByType',
    params,
  };
  return fetch(opt);
}

export async function getArticlesByType(params) {
  const opt = {
    url: '/getArticlesByType',
    params,
  };
  return fetch(opt);
}

export async function deleteArticle(params) {
  const opt = {
    url: '/deleteArticle',
    params,
  };
  return fetch(opt);
}

export async function publish(params) {
  const opt = {
    url: '/publish',
    params,
  };
  return fetch(opt);
}

export async function getPublishedArticleById(params) {
  const opt = {
    url: '/getPublishedArticleById',
    params,
  };
  return fetch(opt);
}

export async function getArticleById(params) {
  const opt = {
    url: '/getArticleById',
    params,
  };
  return fetch(opt);
}

export async function likeArticleById(data) {
  const opt = {
    url: '/likeArticleById',
    method: 'post',
    data,
  };
  return fetch(opt);
}

export async function favoritedArticleById(data) {
  const opt = {
    url: '/favoritedArticleById',
    method: 'post',
    data,
  };
  return fetch(opt);
}

export async function updateArticleById(data) {
  const opt = {
    url: '/updateArticleById',
    method: 'post',
    data,
  };
  return fetch(opt);
}

export async function getRecommended(params) {
  const opt = {
    url: '/getRecommend',
    params,
  };
  return fetch(opt);
}

export async function initialEditor(params) {
  const opt = {
    url: '/initialEditor',
    params,
  };
  return fetch(opt);
}

export async function getDraft(params) {
  const opt = {
    url: '/getDraft',
    params,
  };
  return fetch(opt);
}

export async function getFavorited(params) {
  const opt = {
    url: '/getFavorited',
    params,
  };
  return fetch(opt);
}

export async function getPosts(params) {
  const opt = {
    url: '/getPosts',
    params,
  };
  return fetch(opt);
}

export async function getReview(params) {
  const opt = {
    url: '/getReview',
    params,
  };
  return fetch(opt);
}

export async function commentArticle(data) {
  const opt = {
    url: '/commentArticle',
    method: 'post',
    data,
  };
  return fetch(opt);
}

export async function commentReply(data) {
  const opt = {
    url: '/commentReply',
    method: 'post',
    data,
  };
  return fetch(opt);
}

export async function search(params) {
  const opt = {
    url: '/search',
    params,
  };
  return fetch(opt);
}
